<?php

require_once("scripts/authentication.php");
require_once("scripts/dbconnection.php");

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
	<head>
		<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
		<title>eLibrary Administration : Authors</title>
		<link href="style/defaults.css" rel="stylesheet" type="text/css" media="all" />
		<link href="style/elements.css" rel="stylesheet" type="text/css" media="all" />
		<link href="style/management.css" rel="stylesheet" type="text/css" media="all" />
		
		<script src="js/ajax.js" type="text/javascript"></script>
		<script src="js/author.js" type="text/javascript"></script>
	</head>
	<body>
		
		<div class="header">
			<h1><a href="index.php">eLibrary</a></h1>
			<h3>Administer your library.</h3>
		</div>
		
		<div class="container">
			<h2>Author Management.</h2>
			<div class="column">
				<p class="firstP"></p>
			</div>
			<div class="column">
				<h4>Adding Authors</h4>
				<p>You can add an author before adding a book by using the <a href="author_add.php">Add Author</a> page. You can also import a list of authors from a file on the same page.</p>
			</div>
			<div class="column">
				<h4>Removing Authors</h4>
				<p>To remove an author simply click on their name, then click on "Remove". You will be asked to confirm the removal before it is performed.</p>
			</div>
			
			<div class="separator"></div>
			
			<div class="column">
			
			<!-- Begin List of Authors -->
			
			<?php
			
			// Get all the authors from the database
			$result = mysql_query("SELECT * FROM AUTHOR ORDER BY AuthorName ASC");
			
			// Process the list
			while($row = mysql_fetch_assoc($result))
			{
				?>
				<div class="author" id="Author_<?php echo $row["AuthorID"]; ?>">
					<p class="authorName" id="Author_<?php echo $row["AuthorID"]; ?>_Name" onclick="showSettings(<?php echo $row["AuthorID"]; ?>)"><?php echo $row["AuthorName"]; ?></p>
					<div class="actions hide" id="Author_<?php echo $row["AuthorID"]; ?>_Actions">
						<span class="edit">Edit</span>
						|
						<span class="remove" onclick="removeAuthor(<?php echo $row["AuthorID"]; ?>, '<?php echo $row["AuthorName"]; ?>')">Remove</span>
					</div>
				</div>
				
				<?php
			}
			
			?>
			
			<!-- End List of Authors -->
			
			</div>
			
			<div class="column">
			</div>
			
			<div class="clear"></div>
			
		</div>
	</body>
</html>